package com.xs.boot.controller;

import com.xs.boot.entity.zkyx.Student;
import com.xs.boot.entity.zkyx.WhiteList;
import com.xs.boot.service.zkyx.IQueryStudentService;
import com.xs.boot.service.zkyx.IWhiteListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Controller
@RequestMapping("/zkyx")
public class ZkyxController {

    /*----------------------------------yuan------------------------------*/
    @RequestMapping("/group")
    public String group_register(){
        return "zkyx/group_register";
    }

    /*--------------------------------------------------------------------*/

    /*- ---------------------------------万虎的代码------------------------------*/


    @Autowired
    private IWhiteListService iWhiteListService;

    @Autowired
    private IQueryStudentService iQueryStudentService;

    @RequestMapping("/set_white_list")
    public String set_white_list(){
        return "zkyx/set_white_list";
    }

    @RequestMapping(value = "/add_white_list", method = {RequestMethod.POST})
    @ResponseBody
    public WhiteList addWhiteList(@RequestBody WhiteList whiteList, Model model){
        iWhiteListService.insert(whiteList);
        return whiteList;
    }

    @RequestMapping(value = "/del_white_list", method = {RequestMethod.POST})
    @ResponseBody
    public WhiteList delWhiteList(@RequestBody WhiteList whiteList, Model model){
        iWhiteListService.delete(whiteList);
        return whiteList;
    }

    @RequestMapping("/query_student")
    public String query_student(){
        return "zkyx/query_student";
    }

    @RequestMapping(value = "/query_students", method = {RequestMethod.POST})
    @ResponseBody
    public Student QueryStudent(@RequestBody Student student, Model model){
        return iQueryStudentService.query(student);
    }


    @RequestMapping("/alter_county")
    public String alter_county(){
        return "zkyx/alter_county";
    }

    @RequestMapping(value = "/alter_countys", method = {RequestMethod.POST})
    @ResponseBody
    public Student AlterCounty(@RequestBody Student student, Model model){
        return iQueryStudentService.alter_county(student);
    }

    /*--------------------------------------------------------------------*/
}
